<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../style/js/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="../style/js/ajaxfileupload.js"></script>
    <script type="text/javascript">
        function fileUpload(){
            $.ajaxFileUpload({
                    url: '../admin/fileUpload', //用于文件上传的服务器端请求地址  调用后端接口(interface)
                    fileElementId: 'fileID', //文件上传域的ID
                    dataType: 'json', //返回值类型 一般设置为json
                    success: function (data){
                      if(data.code==200){
                          var account =  window.sessionStorage.getItem("account");//获取到当前登录人账号
                          var imgsrc =  "http://127.0.0.1:8080/tomorrowNewsFiles/admin/"+account+"/"+data.data.newFileName;
                          window.parent.document.getElementById("imgId").innerHTML = "<img src='"+imgsrc+"' width='50' height='50'/>";
                          location.replace("admin_main.html")
                      }else{
                          alert(data.msg);
                      }
                    }
                })
        }
    </script>
</head>
<body>
  上传管路员头像
   <input type="file" name="fileName" accept=".jpg,.png,.gif" id="fileID">
   <input type="button" value="上传" onclick="fileUpload()">
</body>
</html>